package com.wzy.level.category.categoryServlet;

import com.wzy.Jdbc封装.pojo.News_category;
import com.wzy.Jdbc封装.pojo.News_user;
import com.wzy.level.category.categoryService.categoryService;
import com.wzy.level.category.categoryServiceImpl.categoryServiceImpl;
import com.wzy.level.user.userService.userService;
import com.wzy.level.user.userServiceImpl.userServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/category_delete")
public class category_delete extends HttpServlet {
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id = Integer.parseInt(req.getParameter("id"));
        News_category category1 = new News_category();
        category1.setId(id);
        categoryService category = new categoryServiceImpl();
        int i = category.deleteById(id);
//        req.setAttribute("rows",i);
        if(i>0){
//            req.getRequestDispatcher("/pageManage?cate=2").forward(req,resp);
            resp.sendRedirect("http://localhost:8080/pageManage?cate=4");
        }else {
            System.out.println("删除失败");
        }
    }
}
